class Solution
{
public:
    void setZeroes(vector<vector<int>>& matrix)
    {
        int m = matrix.size();
        int n = matrix[0].size();
        vector<int> row(m), column(n);
        for (int i = 0; i < m; i++)
            for (int j = 0; j < n; j++)
                if (!matrix[i][j])
                    row[i] = column[j] = true;

        for (int i = 0; i < m; i++)
            for (int j = 0; j < n; j++)
                if (row[i] || column[j])
                    matrix[i][j] = 0;
    }
};